package cn.school.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.school.common.annotation.Log;
import cn.school.common.core.controller.BaseController;
import cn.school.common.core.domain.AjaxResult;
import cn.school.common.enums.BusinessType;
import cn.school.system.domain.BiCommission;
import cn.school.system.service.IBiCommissionService;
import cn.school.common.utils.poi.ExcelUtil;
import cn.school.common.core.page.TableDataInfo;

/**
 * 佣金明细信息Controller
 *
 * @author asheng
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/system/commission")
public class BiCommissionController extends BaseController
{
    @Autowired
    private IBiCommissionService biCommissionService;

    /**
     * 查询佣金明细信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:commission:list')")
    @GetMapping("/list")
    public TableDataInfo list(BiCommission biCommission)
    {
        startPage();
        List<BiCommission> list = biCommissionService.selectBiCommissionList(biCommission);
        return getDataTable(list);
    }

    /**
     * 导出佣金明细信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:commission:export')")
    @Log(title = "佣金明细信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BiCommission biCommission)
    {
        List<BiCommission> list = biCommissionService.selectBiCommissionList(biCommission);
        ExcelUtil<BiCommission> util = new ExcelUtil<BiCommission>(BiCommission.class);
        util.exportExcel(response, list, "佣金明细信息数据");
    }

    /**
     * 获取佣金明细信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:commission:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(biCommissionService.selectBiCommissionById(id));
    }

    /**
     * 新增佣金明细信息
     */
    @PreAuthorize("@ss.hasPermi('system:commission:add')")
    @Log(title = "佣金明细信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BiCommission biCommission)
    {
        return toAjax(biCommissionService.insertBiCommission(biCommission));
    }

    /**
     * 修改佣金明细信息
     */
    @PreAuthorize("@ss.hasPermi('system:commission:edit')")
    @Log(title = "佣金明细信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BiCommission biCommission)
    {
        return toAjax(biCommissionService.updateBiCommission(biCommission));
    }

    /**
     * 删除佣金明细信息
     */
    @PreAuthorize("@ss.hasPermi('system:commission:remove')")
    @Log(title = "佣金明细信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(biCommissionService.deleteBiCommissionByIds(ids));
    }
}
